{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "312147e4",
   "metadata": {},
   "source": [
    "# Chapter 9"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4c5bd4f7",
   "metadata": {},
   "source": [
    "Script 9-1: K-means clustering"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "0cefda92",
   "metadata": {},
   "outputs": [],
   "source": [
    "#import packages needed\n",
    "import pandas as pd\n",
    "from sklearn.cluster import KMeans\n",
    "import igraph as ig\n",
    "from igraph import Graph\n",
    "import numpy as np\n",
    "import os\n",
    "from scipy.spatial.distance import pdist"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "a8a89244",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Individual ID</th>\n",
       "      <th>Current Teammates</th>\n",
       "      <th>Workout Together</th>\n",
       "      <th>Weekend Sports</th>\n",
       "      <th>Attended Game</th>\n",
       "      <th>Homework Together</th>\n",
       "      <th>Class 1</th>\n",
       "      <th>Class 2</th>\n",
       "      <th>Class 3</th>\n",
       "      <th>Class 4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>8</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>9</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>10</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>11</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>12</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>13</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>14</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>15</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>16</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>17</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>18</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>19</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>20</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>21</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>22</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>23</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>24</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>25</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Individual ID  Current Teammates  Workout Together  Weekend Sports  \\\n",
       "0               1                  1                 1               0   \n",
       "1               2                  1                 1               1   \n",
       "2               3                  1                 1               1   \n",
       "3               4                  1                 1               1   \n",
       "4               5                  1                 1               0   \n",
       "5               6                  0                 1               0   \n",
       "6               7                  0                 1               1   \n",
       "7               8                  1                 0               0   \n",
       "8               9                  1                 0               0   \n",
       "9              10                  1                 0               0   \n",
       "10             11                  0                 0               0   \n",
       "11             12                  1                 0               0   \n",
       "12             13                  0                 0               0   \n",
       "13             14                  1                 0               0   \n",
       "14             15                  1                 0               0   \n",
       "15             16                  1                 0               0   \n",
       "16             17                  1                 0               0   \n",
       "17             18                  0                 0               0   \n",
       "18             19                  1                 0               0   \n",
       "19             20                  0                 0               0   \n",
       "20             21                  0                 0               0   \n",
       "21             22                  1                 0               0   \n",
       "22             23                  1                 0               0   \n",
       "23             24                  0                 0               0   \n",
       "24             25                  0                 0               0   \n",
       "\n",
       "    Attended Game  Homework Together  Class 1  Class 2  Class 3  Class 4  \n",
       "0               1                  1        1        0        0        1  \n",
       "1               1                  1        1        1        1        0  \n",
       "2               1                  1        1        0        1        0  \n",
       "3               1                  1        0        1        0        1  \n",
       "4               1                  1        0        1        0        1  \n",
       "5               1                  1        0        0        1        0  \n",
       "6               1                  1        0        0        1        1  \n",
       "7               1                  0        0        1        0        1  \n",
       "8               1                  0        0        1        0        0  \n",
       "9               1                  1        0        0        1        1  \n",
       "10              0                  0        1        0        0        0  \n",
       "11              0                  0        0        1        0        0  \n",
       "12              0                  0        1        1        0        0  \n",
       "13              1                  0        1        0        0        0  \n",
       "14              0                  0        1        0        0        1  \n",
       "15              0                  0        0        1        0        0  \n",
       "16              0                  0        0        0        1        0  \n",
       "17              0                  0        1        0        0        0  \n",
       "18              1                  1        1        1        0        0  \n",
       "19              0                  0        0        0        1        0  \n",
       "20              0                  1        0        0        1        1  \n",
       "21              0                  0        0        0        0        0  \n",
       "22              0                  0        0        1        0        0  \n",
       "23              0                  0        0        1        0        0  \n",
       "24              0                  0        0        1        0        0  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#import file\n",
    "File =\"/Users/franckm/Documents/draftcodefiles/Friendship_Factors.csv\"\n",
    "pwd = os.getcwd()\n",
    "os.chdir(os.path.dirname(File))\n",
    "mydata = pd.read_csv(os.path.basename(File),encoding='latin1')\n",
    "mydata"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "233d8ff9",
   "metadata": {},
   "outputs": [],
   "source": [
    "#k-means model\n",
    "X=mydata[mydata.columns.drop('Individual ID')]\n",
    "km=KMeans(n_clusters=3,init='random',n_init=5)\n",
    "km_model=km.fit_predict(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "7e85eb8b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 1, 2, 1, 2, 2, 2, 2, 1, 2, 1, 0, 2,\n",
       "       2, 1, 1], dtype=int32)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#explore k-means model\n",
    "km_model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "85c5a1ed",
   "metadata": {},
   "outputs": [],
   "source": [
    "#add to dataset as first solution\n",
    "km_1=np.array(km_model)+1\n",
    "mydata['km_1']=km_1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "02237919",
   "metadata": {},
   "outputs": [],
   "source": [
    "#create network via Pearson correlation\n",
    "cor=np.corrcoef(X)\n",
    "cor[cor>=0.5]=1\n",
    "cor[cor<0.5]=0\n",
    "X2=np.asmatrix(cor)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "7571dca5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600pt\" height=\"600pt\" viewBox=\"0 0 600 600\" version=\"1.1\">\n",
       "<g id=\"surface2\">\n",
       "<rect x=\"0\" y=\"0\" width=\"600\" height=\"600\" style=\"fill:rgb(100%,100%,100%);fill-opacity:1;stroke:none;\"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 64.621094 176.652344 C 109.460938 186.816406 147.617188 173.730469 165.347656 131.605469 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 170.882812 118.457031 L 169.621094 133.402344 L 161.078125 129.808594 L 170.882812 118.457031 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 64.621094 176.652344 C 54.894531 198.207031 78.710938 229.363281 76.984375 232.046875 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 69.257812 244.039062 L 73.085938 229.539062 L 80.878906 234.558594 L 69.257812 244.039062 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 64.621094 176.652344 C 35.695312 195.480469 48.089844 241.527344 36.195312 254.464844 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 26.539062 264.964844 L 32.78125 251.324219 L 39.609375 257.601562 L 26.539062 264.964844 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 551.625 102.265625 C 538.960938 122.003906 543.132812 160.210938 555.726562 158.398438 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 569.847656 156.367188 L 556.386719 162.988281 L 555.066406 153.8125 L 569.847656 156.367188 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 580 154.90625 C 574.046875 127.085938 553.351562 101.683594 528.511719 110.070312 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 542.027344 105.507812 L 529.992188 114.464844 L 527.027344 105.679688 L 542.027344 105.507812 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 175.167969 20 C 145.757812 42.085938 131.644531 101.148438 150.503906 104.753906 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 164.515625 107.4375 L 149.632812 109.308594 L 151.375 100.203125 L 164.515625 107.4375 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 174.703125 109.382812 C 130.976562 101.183594 104.496094 120.8125 78.9375 156.605469 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 70.644531 168.214844 L 75.164062 153.914062 L 82.707031 159.300781 L 70.644531 168.214844 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 174.703125 109.382812 C 190.5 87.292969 171.625 64.101562 173.222656 44.226562 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 174.363281 30.007812 L 177.84375 44.597656 L 168.601562 43.855469 L 174.363281 30.007812 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 174.703125 109.382812 C 191.367188 144.171875 219.582031 161.742188 256.792969 152.179688 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 270.609375 148.628906 L 257.949219 156.667969 L 255.640625 147.691406 L 270.609375 148.628906 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 174.703125 109.382812 C 171.328125 140.574219 185.085938 176.042969 213.132812 174.128906 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 227.367188 173.15625 L 213.449219 178.753906 L 212.816406 169.503906 L 227.367188 173.15625 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 261.683594 580 C 299.578125 595.035156 332.132812 553.511719 356.09375 554.300781 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 341.835938 553.832031 L 356.246094 549.667969 L 355.941406 558.933594 L 341.835938 553.832031 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 332.027344 553.507812 C 311.628906 547.457031 300.195312 565.027344 284.144531 571.265625 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 270.847656 576.4375 L 282.464844 566.945312 L 285.824219 575.585938 L 270.847656 576.4375 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 332.027344 553.507812 C 373.84375 566.980469 427.277344 516.847656 431.710938 519.164062 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 419.066406 512.558594 L 433.855469 515.054688 L 429.5625 523.273438 L 419.066406 512.558594 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 279.988281 146.21875 C 263.601562 111.617188 235.703125 94.132812 198.699219 103.382812 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 184.859375 106.84375 L 197.574219 98.886719 L 199.824219 107.878906 L 184.859375 106.84375 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 279.988281 146.21875 C 253.765625 135.691406 222.308594 166.757812 214.476562 163.769531 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 227.804688 168.855469 L 212.824219 168.101562 L 216.128906 159.4375 L 227.804688 168.855469 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 279.988281 146.21875 C 269.835938 170.234375 275.898438 208.078125 295.070312 206.949219 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 309.3125 206.109375 L 295.34375 211.574219 L 294.796875 202.320312 L 309.3125 206.109375 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 279.988281 146.21875 C 256.71875 166.039062 248.050781 215.773438 263.851562 217.78125 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 278.003906 219.582031 L 263.269531 222.382812 L 264.4375 213.183594 L 278.003906 219.582031 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 279.988281 146.21875 C 261.621094 178.410156 263.792969 232.820312 291.074219 234.480469 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 305.3125 235.34375 L 290.792969 239.105469 L 291.355469 229.851562 L 305.3125 235.34375 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 237.308594 172.476562 C 238.992188 143.496094 226.960938 120.277344 198.804688 114.40625 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 184.839844 111.496094 L 199.75 109.871094 L 197.859375 118.945312 L 184.839844 111.496094 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 237.308594 172.476562 C 248.242188 173.394531 252.203125 162.96875 259.621094 158.496094 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 271.839844 151.132812 L 262.011719 162.464844 L 257.226562 154.527344 L 271.839844 151.132812 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 237.308594 172.476562 C 247.066406 199.96875 267.714844 217.90625 295.632812 211.207031 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 309.503906 207.878906 L 296.714844 215.714844 L 294.550781 206.699219 L 309.503906 207.878906 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 237.308594 172.476562 C 233.65625 196.132812 243.8125 225.097656 264.359375 223.15625 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 278.5625 221.8125 L 264.796875 227.769531 L 263.921875 218.542969 L 278.5625 221.8125 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 237.308594 172.476562 C 208.585938 152.925781 181.457031 155.019531 154.011719 176.296875 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 142.738281 185.039062 L 151.171875 172.636719 L 156.851562 179.960938 L 142.738281 185.039062 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 237.308594 172.476562 C 238.632812 207.902344 257.832031 242.214844 290.863281 238.585938 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 305.042969 237.03125 L 291.367188 243.195312 L 290.355469 233.980469 L 305.042969 237.03125 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 465.773438 542.269531 C 464.960938 521.496094 452.925781 500.140625 434.300781 503.550781 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 420.265625 506.117188 L 433.464844 498.988281 L 435.132812 508.109375 L 420.265625 506.117188 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 57.609375 340.15625 C 101.925781 372.746094 161.28125 328.898438 189.621094 338.914062 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 176.167969 334.160156 L 191.164062 334.546875 L 188.074219 343.285156 L 176.167969 334.160156 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 57.609375 340.15625 C 89.394531 318.789062 101.195312 254 87.863281 253.359375 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 73.613281 252.675781 L 88.085938 248.730469 L 87.640625 257.992188 L 73.613281 252.675781 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 57.609375 340.15625 C 70.554688 313.25 63.878906 267.972656 43.714844 269.859375 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 29.511719 271.1875 L 43.285156 265.246094 L 44.148438 274.472656 L 29.511719 271.1875 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 57.609375 340.15625 C 80.195312 343.890625 94.523438 315.96875 106.347656 314.800781 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 92.152344 316.203125 L 105.894531 310.1875 L 106.804688 319.414062 L 92.152344 316.203125 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 319.328125 205.519531 C 316.226562 184.613281 284.050781 175.511719 283.265625 169.84375 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 281.304688 155.710938 L 287.855469 169.207031 L 278.671875 170.480469 L 281.304688 155.710938 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 319.328125 205.519531 C 309.171875 179.105469 289.851562 165.933594 261.789062 169.429688 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 247.632812 171.191406 L 261.214844 164.828125 L 262.363281 174.027344 L 247.632812 171.191406 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 319.328125 205.519531 C 297.175781 196.835938 278.710938 220.835938 264.285156 220.746094 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 278.550781 220.835938 L 264.257812 225.382812 L 264.3125 216.113281 L 278.550781 220.835938 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 319.328125 205.519531 C 319.398438 235.472656 335.476562 266.65625 362.59375 262.929688 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 376.726562 260.988281 L 363.226562 267.519531 L 361.964844 258.335938 L 376.726562 260.988281 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 319.328125 205.519531 C 302.320312 208.535156 292.785156 235.8125 291.011719 235.800781 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 305.277344 235.882812 L 290.984375 240.4375 L 291.035156 231.167969 L 305.277344 235.882812 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 319.328125 205.519531 C 281.40625 214.109375 240.636719 257.816406 258.882812 276.621094 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 268.816406 286.859375 L 255.554688 279.847656 L 262.210938 273.394531 L 268.816406 286.859375 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 319.328125 205.519531 C 284.136719 200.367188 239.308594 217.417969 244.339844 246.308594 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 246.785156 260.363281 L 239.773438 247.101562 L 248.90625 245.511719 L 246.785156 260.363281 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 167.570312 331.121094 C 138.546875 309.519531 113.210938 319.210938 80.738281 331.445312 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 67.386719 336.476562 L 79.101562 327.109375 L 82.371094 335.78125 L 67.386719 336.476562 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 167.570312 331.121094 C 152.378906 308.835938 132.183594 302.625 106.308594 310.207031 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 92.621094 314.21875 L 105.007812 305.761719 L 107.613281 314.65625 L 92.621094 314.21875 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 167.570312 331.121094 C 204.625 352.039062 258.015625 353.59375 268.832031 317.925781 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 272.972656 304.273438 L 273.269531 319.269531 L 264.398438 316.578125 L 272.972656 304.273438 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 167.570312 331.121094 C 207.960938 341.140625 269.789062 312.292969 259.550781 292.199219 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 253.078125 279.488281 L 263.683594 290.097656 L 255.421875 294.304688 L 253.078125 279.488281 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 63.988281 252.214844 C 90.675781 233.996094 101.628906 179.925781 88.992188 178.808594 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 74.78125 177.550781 L 89.402344 174.191406 L 88.582031 183.425781 L 74.78125 177.550781 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 63.988281 252.214844 C 49.753906 279.195312 73.597656 326.183594 75.507812 324.515625 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 64.765625 333.902344 L 72.457031 321.027344 L 78.558594 328.003906 L 64.765625 333.902344 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 63.988281 252.214844 C 54.277344 250.695312 49.757812 260.765625 43.148438 263.277344 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 29.816406 268.347656 L 41.503906 258.945312 L 44.796875 267.613281 L 29.816406 268.347656 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 63.988281 252.214844 C 64.238281 278.066406 90.28125 310.875 101.695312 301.488281 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 90.675781 310.546875 L 98.753906 297.90625 L 104.640625 305.070312 L 90.675781 310.546875 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 63.988281 252.214844 C 105.617188 259.238281 160.695312 210.839844 154.023438 205.757812 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 142.675781 197.113281 L 156.832031 202.070312 L 151.214844 209.441406 L 142.675781 197.113281 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 20 272.078125 C 64.964844 259.304688 99.160156 185.765625 87.933594 182.804688 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 74.140625 179.164062 L 89.117188 178.320312 L 86.75 187.285156 L 74.140625 179.164062 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 20 272.078125 C 25.53125 304.828125 56.414062 340.9375 77.78125 326.992188 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 65.835938 334.789062 L 75.25 323.109375 L 80.316406 330.871094 L 65.835938 334.789062 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 20 272.078125 C 47.753906 282.117188 69.527344 252.023438 87.742188 251.386719 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 73.488281 251.886719 L 87.582031 246.753906 L 87.90625 256.019531 L 73.488281 251.886719 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 20 272.078125 C 39.671875 304.25 71.824219 323.007812 104.097656 305.523438 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 91.554688 312.320312 L 101.886719 301.449219 L 106.304688 309.601562 L 91.554688 312.320312 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 288.300781 220.894531 C 297.933594 202.011719 279.375 185.054688 279.601562 170.765625 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 279.828125 156.503906 L 284.238281 170.839844 L 274.96875 170.695312 L 279.828125 156.503906 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 288.300781 220.894531 C 289.261719 200.214844 280.09375 186.066406 260.367188 179.800781 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 246.769531 175.484375 L 261.769531 175.382812 L 258.964844 184.21875 L 246.769531 175.484375 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 288.300781 220.894531 C 292.347656 221.839844 294.34375 218.488281 297.433594 216.886719 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 310.097656 210.3125 L 299.570312 221 L 295.300781 212.769531 L 310.097656 210.3125 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 288.300781 220.894531 C 302.164062 254.40625 328.207031 273.699219 363.175781 265.273438 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 377.046875 261.929688 L 364.261719 269.777344 L 362.089844 260.765625 L 377.046875 261.929688 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 288.300781 220.894531 C 284.121094 228.40625 286.660156 242.335938 291.09375 241.335938 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 305.007812 238.195312 L 292.113281 245.855469 L 290.074219 236.8125 L 305.007812 238.195312 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 288.300781 220.894531 C 262.542969 232.8125 240.109375 270.222656 256.007812 280.871094 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 267.859375 288.808594 L 253.425781 284.722656 L 258.585938 277.019531 L 267.859375 288.808594 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 288.300781 220.894531 C 266.324219 218.121094 237.53125 230.59375 242.113281 247.21875 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 245.90625 260.972656 L 237.648438 248.453125 L 246.582031 245.988281 L 245.90625 260.972656 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 457.484375 341.148438 C 429.578125 363.273438 414.957031 418.203125 435.765625 423.8125 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 449.539062 427.527344 L 434.558594 428.289062 L 436.972656 419.339844 L 449.539062 427.527344 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 457.484375 341.148438 C 457.914062 305.507812 436.433594 290.101562 406.992188 272.101562 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 394.820312 264.660156 L 409.410156 268.148438 L 404.574219 276.054688 L 394.820312 264.660156 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 82.664062 317.136719 C 78.203125 321.566406 79.546875 332.390625 80.476562 332.0625 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 67.03125 336.824219 L 78.929688 327.691406 L 82.023438 336.429688 L 67.03125 336.824219 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 82.664062 317.136719 C 116.34375 344.441406 148.570312 341.136719 186.644531 321.066406 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 174.023438 327.71875 L 184.484375 316.964844 L 188.804688 325.167969 L 174.023438 327.71875 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 82.664062 317.136719 C 101.097656 296.558594 101.894531 250.453125 88.421875 251.082031 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 74.171875 251.742188 L 88.207031 246.449219 L 88.636719 255.710938 L 74.171875 251.742188 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 82.664062 317.136719 C 82.148438 291.058594 67.371094 263.703125 44.121094 267.8125 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 30.074219 270.296875 L 43.316406 263.25 L 44.929688 272.378906 L 30.074219 270.296875 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 134.851562 191.152344 C 163.769531 210.476562 190.292969 207.265625 218.199219 186.617188 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 229.667969 178.128906 L 220.957031 190.339844 L 215.445312 182.890625 L 229.667969 178.128906 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 134.851562 191.152344 C 106.019531 193.183594 99.910156 221.714844 82.414062 236.574219 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 71.539062 245.804688 L 79.414062 233.039062 L 85.414062 240.105469 L 71.539062 245.804688 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 459.386719 430.183594 C 477.957031 409.679688 474.464844 389.585938 465.519531 364.074219 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 460.800781 350.609375 L 469.894531 362.539062 L 461.144531 365.605469 L 460.800781 350.609375 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 459.386719 430.183594 C 430.632812 436.769531 417.859375 455.144531 413.664062 484.234375 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 411.628906 498.355469 L 409.074219 483.574219 L 418.25 484.898438 L 411.628906 498.355469 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 410.242188 507.949219 C 382.890625 504.644531 372.101562 529.542969 352.960938 540.988281 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 340.71875 548.3125 L 350.582031 537.011719 L 355.339844 544.96875 L 340.71875 548.3125 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 410.242188 507.949219 C 415.035156 524.589844 428.613281 526.855469 443.40625 532.992188 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 456.582031 538.457031 L 441.628906 537.273438 L 445.179688 528.710938 L 456.582031 538.457031 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 410.242188 507.949219 C 444.75 504.542969 484.660156 474.773438 471.59375 451.71875 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 464.558594 439.308594 L 475.625 449.433594 L 467.5625 454.007812 L 464.558594 439.308594 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 386.589844 259.632812 C 380.867188 234.429688 357.382812 232.105469 339.3125 219.484375 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 327.621094 211.3125 L 341.96875 215.683594 L 336.660156 223.28125 L 327.621094 211.3125 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 386.589844 259.632812 C 372.699219 226.652344 347.496094 209.671875 312.429688 216.320312 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 298.410156 218.976562 L 311.566406 211.765625 L 313.289062 220.875 L 298.410156 218.976562 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 386.589844 259.632812 C 381.539062 299.089844 398.40625 344.929688 433.710938 342.667969 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 447.945312 341.757812 L 434.003906 347.296875 L 433.414062 338.042969 L 447.945312 341.757812 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 386.589844 259.632812 C 376.21875 240.394531 359.917969 239.121094 338.976562 237.636719 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 324.746094 236.625 L 339.304688 233.011719 L 338.648438 242.257812 L 324.746094 236.625 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 315.015625 235.933594 C 324.914062 207.269531 307.574219 190.371094 292.75 166.640625 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 285.1875 154.542969 L 296.679688 164.183594 L 288.816406 169.097656 L 285.1875 154.542969 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 315.015625 235.933594 C 312.640625 202.25 295.328125 177.65625 261.957031 174.679688 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 247.746094 173.410156 L 262.367188 170.0625 L 261.542969 179.296875 L 247.746094 173.410156 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 315.015625 235.933594 C 313.898438 227.667969 305.003906 218.117188 300.96875 221.664062 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 311.683594 212.242188 L 304.027344 225.144531 L 297.90625 218.183594 L 311.683594 212.242188 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 315.015625 235.933594 C 306.449219 233.785156 293.710938 238.4375 295.472656 244.136719 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 291.265625 230.503906 L 299.902344 242.769531 L 291.042969 245.503906 L 291.265625 230.503906 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 315.015625 235.933594 C 323.503906 257.886719 340.5 271.765625 362.925781 265.859375 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 376.722656 262.230469 L 364.105469 270.34375 L 361.746094 261.378906 L 376.722656 262.230469 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 315.015625 235.933594 C 288.871094 235.59375 255.554688 256.910156 264.324219 272.925781 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 271.171875 285.4375 L 260.257812 275.152344 L 268.390625 270.699219 L 271.171875 285.4375 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 315.015625 235.933594 C 292.9375 225.785156 266.96875 226.949219 258.015625 248.234375 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 252.480469 261.382812 L 253.742188 246.4375 L 262.285156 250.03125 L 252.480469 261.382812 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 276.003906 294.265625 C 306.113281 283.03125 315.367188 261.0625 317.628906 229.34375 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 318.644531 215.113281 L 322.253906 229.671875 L 313.007812 229.011719 L 318.644531 215.113281 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 276.003906 294.265625 C 240.9375 280.101562 218.28125 297.9375 188.277344 317.570312 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 176.339844 325.382812 L 185.738281 313.691406 L 190.8125 321.449219 L 176.339844 325.382812 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 276.003906 294.265625 C 296.9375 282.828125 310.578125 262.378906 299.722656 242.164062 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 292.972656 229.59375 L 303.804688 239.96875 L 295.640625 244.355469 L 292.972656 229.59375 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 276.003906 294.265625 C 295.855469 291.082031 305.015625 279.046875 309.535156 259.566406 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 312.757812 245.667969 L 314.050781 260.613281 L 305.019531 258.519531 L 312.757812 245.667969 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 276.003906 294.265625 C 281.46875 284.75 279.496094 267.421875 272.792969 268.125 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 258.601562 269.609375 L 272.308594 263.515625 L 273.273438 272.734375 L 258.601562 269.609375 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 248.578125 270.660156 C 279.113281 270.339844 291.410156 251.140625 306.75 226.078125 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 314.195312 213.910156 L 310.703125 228.496094 L 302.796875 223.65625 L 314.195312 213.910156 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 248.578125 270.660156 C 216.488281 269.414062 205.757812 295.027344 185.175781 314.480469 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 174.808594 324.277344 L 181.992188 311.109375 L 188.359375 317.847656 L 174.808594 324.277344 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 248.578125 270.660156 C 266.117188 270.027344 276.328125 260.996094 281.34375 244.195312 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 285.425781 230.523438 L 285.785156 245.519531 L 276.902344 242.867188 L 285.425781 230.523438 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 248.578125 270.660156 C 269.507812 277.304688 283.339844 268.867188 298.328125 253.28125 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 308.21875 243 L 301.671875 256.496094 L 294.988281 250.070312 L 308.21875 243 \"/>\n",
       "<path style=\"fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(26.666667%,26.666667%,26.666667%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 248.578125 270.660156 C 244.617188 278.542969 245.261719 290.671875 252.328125 291.5 \"/>\n",
       "<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(26.666667%,26.666667%,26.666667%);fill-opacity:1;\" d=\"M 266.496094 293.15625 L 251.789062 296.101562 L 252.863281 286.894531 L 266.496094 293.15625 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 74.621094 176.652344 C 74.621094 182.175781 70.144531 186.652344 64.621094 186.652344 C 59.097656 186.652344 54.621094 182.175781 54.621094 176.652344 C 54.621094 171.128906 59.097656 166.652344 64.621094 166.652344 C 70.144531 166.652344 74.621094 171.128906 74.621094 176.652344 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 561.625 102.265625 C 561.625 107.789062 557.148438 112.265625 551.625 112.265625 C 546.101562 112.265625 541.625 107.789062 541.625 102.265625 C 541.625 96.746094 546.101562 92.265625 551.625 92.265625 C 557.148438 92.265625 561.625 96.746094 561.625 102.265625 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 590 154.90625 C 590 160.425781 585.523438 164.90625 580 164.90625 C 574.476562 164.90625 570 160.425781 570 154.90625 C 570 149.382812 574.476562 144.90625 580 144.90625 C 585.523438 144.90625 590 149.382812 590 154.90625 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 185.167969 20 C 185.167969 25.523438 180.6875 30 175.167969 30 C 169.644531 30 165.167969 25.523438 165.167969 20 C 165.167969 14.476562 169.644531 10 175.167969 10 C 180.6875 10 185.167969 14.476562 185.167969 20 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 184.703125 109.382812 C 184.703125 114.90625 180.226562 119.382812 174.703125 119.382812 C 169.179688 119.382812 164.703125 114.90625 164.703125 109.382812 C 164.703125 103.859375 169.179688 99.382812 174.703125 99.382812 C 180.226562 99.382812 184.703125 103.859375 184.703125 109.382812 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 271.683594 580 C 271.683594 585.523438 267.203125 590 261.683594 590 C 256.160156 590 251.683594 585.523438 251.683594 580 C 251.683594 574.476562 256.160156 570 261.683594 570 C 267.203125 570 271.683594 574.476562 271.683594 580 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 342.027344 553.507812 C 342.027344 559.03125 337.550781 563.507812 332.027344 563.507812 C 326.503906 563.507812 322.027344 559.03125 322.027344 553.507812 C 322.027344 547.984375 326.503906 543.507812 332.027344 543.507812 C 337.550781 543.507812 342.027344 547.984375 342.027344 553.507812 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 289.988281 146.21875 C 289.988281 151.742188 285.511719 156.21875 279.988281 156.21875 C 274.46875 156.21875 269.988281 151.742188 269.988281 146.21875 C 269.988281 140.695312 274.46875 136.21875 279.988281 136.21875 C 285.511719 136.21875 289.988281 140.695312 289.988281 146.21875 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 247.308594 172.476562 C 247.308594 178 242.832031 182.476562 237.308594 182.476562 C 231.785156 182.476562 227.308594 178 227.308594 172.476562 C 227.308594 166.957031 231.785156 162.476562 237.308594 162.476562 C 242.832031 162.476562 247.308594 166.957031 247.308594 172.476562 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 475.773438 542.269531 C 475.773438 547.792969 471.292969 552.269531 465.773438 552.269531 C 460.25 552.269531 455.773438 547.792969 455.773438 542.269531 C 455.773438 536.746094 460.25 532.269531 465.773438 532.269531 C 471.292969 532.269531 475.773438 536.746094 475.773438 542.269531 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 67.609375 340.15625 C 67.609375 345.679688 63.132812 350.15625 57.609375 350.15625 C 52.089844 350.15625 47.609375 345.679688 47.609375 340.15625 C 47.609375 334.632812 52.089844 330.15625 57.609375 330.15625 C 63.132812 330.15625 67.609375 334.632812 67.609375 340.15625 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 329.328125 205.519531 C 329.328125 211.042969 324.851562 215.519531 319.328125 215.519531 C 313.808594 215.519531 309.328125 211.042969 309.328125 205.519531 C 309.328125 199.996094 313.808594 195.519531 319.328125 195.519531 C 324.851562 195.519531 329.328125 199.996094 329.328125 205.519531 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 177.570312 331.121094 C 177.570312 336.644531 173.09375 341.121094 167.570312 341.121094 C 162.046875 341.121094 157.570312 336.644531 157.570312 331.121094 C 157.570312 325.597656 162.046875 321.121094 167.570312 321.121094 C 173.09375 321.121094 177.570312 325.597656 177.570312 331.121094 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 73.988281 252.214844 C 73.988281 257.738281 69.511719 262.214844 63.988281 262.214844 C 58.464844 262.214844 53.988281 257.738281 53.988281 252.214844 C 53.988281 246.695312 58.464844 242.214844 63.988281 242.214844 C 69.511719 242.214844 73.988281 246.695312 73.988281 252.214844 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 30 272.078125 C 30 277.601562 25.523438 282.078125 20 282.078125 C 14.476562 282.078125 10 277.601562 10 272.078125 C 10 266.554688 14.476562 262.078125 20 262.078125 C 25.523438 262.078125 30 266.554688 30 272.078125 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 298.300781 220.894531 C 298.300781 226.417969 293.824219 230.894531 288.300781 230.894531 C 282.777344 230.894531 278.300781 226.417969 278.300781 220.894531 C 278.300781 215.371094 282.777344 210.894531 288.300781 210.894531 C 293.824219 210.894531 298.300781 215.371094 298.300781 220.894531 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 467.484375 341.148438 C 467.484375 346.667969 463.003906 351.148438 457.484375 351.148438 C 451.960938 351.148438 447.484375 346.667969 447.484375 341.148438 C 447.484375 335.625 451.960938 331.148438 457.484375 331.148438 C 463.003906 331.148438 467.484375 335.625 467.484375 341.148438 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 92.664062 317.136719 C 92.664062 322.660156 88.1875 327.136719 82.664062 327.136719 C 77.140625 327.136719 72.664062 322.660156 72.664062 317.136719 C 72.664062 311.613281 77.140625 307.136719 82.664062 307.136719 C 88.1875 307.136719 92.664062 311.613281 92.664062 317.136719 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 144.851562 191.152344 C 144.851562 196.675781 140.375 201.152344 134.851562 201.152344 C 129.332031 201.152344 124.851562 196.675781 124.851562 191.152344 C 124.851562 185.632812 129.332031 181.152344 134.851562 181.152344 C 140.375 181.152344 144.851562 185.632812 144.851562 191.152344 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 469.386719 430.183594 C 469.386719 435.707031 464.910156 440.183594 459.386719 440.183594 C 453.863281 440.183594 449.386719 435.707031 449.386719 430.183594 C 449.386719 424.660156 453.863281 420.183594 459.386719 420.183594 C 464.910156 420.183594 469.386719 424.660156 469.386719 430.183594 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 420.242188 507.949219 C 420.242188 513.472656 415.765625 517.949219 410.242188 517.949219 C 404.71875 517.949219 400.242188 513.472656 400.242188 507.949219 C 400.242188 502.425781 404.71875 497.949219 410.242188 497.949219 C 415.765625 497.949219 420.242188 502.425781 420.242188 507.949219 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 396.589844 259.632812 C 396.589844 265.152344 392.113281 269.632812 386.589844 269.632812 C 381.066406 269.632812 376.589844 265.152344 376.589844 259.632812 C 376.589844 254.109375 381.066406 249.632812 386.589844 249.632812 C 392.113281 249.632812 396.589844 254.109375 396.589844 259.632812 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 325.015625 235.933594 C 325.015625 241.457031 320.535156 245.933594 315.015625 245.933594 C 309.492188 245.933594 305.015625 241.457031 305.015625 235.933594 C 305.015625 230.414062 309.492188 225.933594 315.015625 225.933594 C 320.535156 225.933594 325.015625 230.414062 325.015625 235.933594 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 286.003906 294.265625 C 286.003906 299.789062 281.527344 304.265625 276.003906 304.265625 C 270.484375 304.265625 266.003906 299.789062 266.003906 294.265625 C 266.003906 288.742188 270.484375 284.265625 276.003906 284.265625 C 281.527344 284.265625 286.003906 288.742188 286.003906 294.265625 \"/>\n",
       "<path style=\"fill-rule:nonzero;fill:rgb(100%,0%,0%);fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" d=\"M 258.578125 270.660156 C 258.578125 276.179688 254.101562 280.660156 248.578125 280.660156 C 243.054688 280.660156 238.578125 276.179688 238.578125 270.660156 C 238.578125 265.136719 243.054688 260.660156 248.578125 260.660156 C 254.101562 260.660156 258.578125 265.136719 258.578125 270.660156 \"/>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<igraph.drawing.cairo.plot.CairoPlot at 0x7fa85844e400>"
      ]
     },
     "execution_count": 7,
     "metadata": {
      "image/svg+xml": {
       "isolated": true
      }
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#create graph with self-loops removed\n",
    "friends=Graph.Adjacency(X2,diag=False)\n",
    "edge_list=friends.get_edgelist()\n",
    "self_loop=[]\n",
    "for i in range(0,25):\n",
    "    self=(i,i)\n",
    "    self_loop.append(self)\n",
    "to_remove=[]\n",
    "for i in edge_list:\n",
    "    for j in self_loop:\n",
    "        if i==j:\n",
    "            to_remove.append(i)\n",
    "friends.delete_edges(to_remove)\n",
    "ig.plot(friends)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "9f404a4b",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/var/folders/31/w56d47t956zfp0kklgtz_yq40000gn/T/ipykernel_3945/1489012741.py:4: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  X['degree']=d\n"
     ]
    }
   ],
   "source": [
    "#create scaled metrics and attach to X\n",
    "d=np.array(Graph.degree(friends))/10\n",
    "p=np.array(Graph.pagerank(friends))*20\n",
    "X['degree']=d\n",
    "X['pagerank']=p"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "5b99e17d",
   "metadata": {},
   "outputs": [],
   "source": [
    "#create new k-means model with graph metrics added\n",
    "km2=KMeans(n_clusters=3,init='random',n_init=5)\n",
    "km_model2=km2.fit_predict(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "00f5ed86",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 2, 0, 2, 2, 2, 0, 2, 2, 1, 2, 2, 2,\n",
       "       0, 0, 0], dtype=int32)"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#explore new k-means model\n",
    "km_model2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "e1a3b63c",
   "metadata": {},
   "outputs": [],
   "source": [
    "#add to dataset as first solution\n",
    "km_2=np.array(km_model2)+1\n",
    "mydata['km_2']=km_2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "74b2f649",
   "metadata": {},
   "outputs": [],
   "source": [
    "#import packages needed\n",
    "from sklearn.cluster import SpectralClustering\n",
    "from sklearn import metrics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "d54aa11f",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/franckm/opt/anaconda3/lib/python3.9/site-packages/sklearn/manifold/_spectral_embedding.py:259: UserWarning: Graph is not fully connected, spectral embedding may not work as expected.\n",
      "  warnings.warn(\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([0, 1, 1, 0, 0, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0,\n",
       "       0, 0, 0], dtype=int32)"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#perform spectral clustering and attach to dataset\n",
    "sc = SpectralClustering(3, affinity='precomputed', n_init=5)\n",
    "sp_clust=sc.fit(cor)\n",
    "mydata['sp']=sp_clust.labels_+1\n",
    "sp_clust.labels_"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c87bc35c",
   "metadata": {},
   "source": [
    "Script 9-2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "c3911fc2",
   "metadata": {},
   "outputs": [],
   "source": [
    "#install packages if you have not installed them on your machine\n",
    "#!pip install dgl\n",
    "#!pip install torch"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "13835420",
   "metadata": {},
   "outputs": [],
   "source": [
    "#import packages\n",
    "import dgl\n",
    "import dgl.data\n",
    "import torch\n",
    "import torch.nn as nn\n",
    "import torch.nn.functional as F\n",
    "import itertools  \n",
    "from dgl.nn import SAGEConv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "447cc46d",
   "metadata": {},
   "outputs": [],
   "source": [
    "#import Karate Club dataset with officer labels\n",
    "dataset = dgl.data.KarateClubDataset()\n",
    "num_classes = dataset.num_classes\n",
    "g = dataset[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "6b9a15b9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Parameter containing:\n",
       "tensor([[-0.1524,  0.2658, -0.2394, -0.3014,  0.3128,  0.1725],\n",
       "        [-0.1249,  0.1549,  0.3465, -0.1081,  0.0964,  0.2661],\n",
       "        [-0.3334, -0.0622,  0.1700, -0.0718, -0.2070,  0.3102],\n",
       "        [ 0.0137,  0.0479,  0.1074, -0.1915, -0.1096, -0.3296],\n",
       "        [ 0.3256, -0.1248, -0.1326,  0.2262, -0.1408,  0.0697],\n",
       "        [-0.0812, -0.1556,  0.0187, -0.1246,  0.3422, -0.1429],\n",
       "        [ 0.2473, -0.1579,  0.0124, -0.0248, -0.2432, -0.0103],\n",
       "        [ 0.3611,  0.3411,  0.0368,  0.2605, -0.1826,  0.3181],\n",
       "        [-0.0070, -0.1894, -0.0031,  0.3710, -0.1623,  0.3739],\n",
       "        [-0.2433, -0.1243, -0.1167, -0.0707,  0.0569,  0.1318],\n",
       "        [ 0.1581,  0.0670,  0.1888, -0.1491,  0.3713, -0.2693],\n",
       "        [-0.0470,  0.0423, -0.3734, -0.0562, -0.1159,  0.3312],\n",
       "        [ 0.1883, -0.3135,  0.0335,  0.3198,  0.1567, -0.0093],\n",
       "        [-0.0469, -0.0168,  0.0716, -0.2215, -0.0942, -0.2874],\n",
       "        [ 0.1846,  0.3422,  0.3204,  0.0393, -0.0798,  0.1451],\n",
       "        [ 0.0765, -0.1620,  0.2936,  0.1877, -0.2512,  0.2821],\n",
       "        [ 0.1036, -0.0689, -0.3808,  0.3127, -0.0460,  0.0057],\n",
       "        [ 0.0697,  0.1818,  0.1668, -0.1317,  0.3620, -0.2892],\n",
       "        [-0.2967, -0.2146, -0.0465,  0.3517, -0.3040,  0.3710],\n",
       "        [ 0.3036, -0.0295, -0.2958,  0.3223, -0.2834,  0.2417],\n",
       "        [-0.3695, -0.2722,  0.0026, -0.2158,  0.1576, -0.0727],\n",
       "        [ 0.0593, -0.2747, -0.3266, -0.2877, -0.0049, -0.1413],\n",
       "        [-0.1048,  0.1991, -0.3157,  0.3680, -0.2931,  0.2477],\n",
       "        [-0.0087, -0.1227,  0.1955,  0.0672,  0.1549, -0.1546],\n",
       "        [-0.3733, -0.1706,  0.0560, -0.1049, -0.1302, -0.3343],\n",
       "        [-0.1633,  0.1198,  0.1619, -0.1755,  0.2205,  0.3375],\n",
       "        [ 0.1362,  0.0734, -0.1864, -0.3848,  0.1563, -0.0090],\n",
       "        [ 0.1586,  0.0472, -0.1766, -0.0726, -0.3352,  0.3652],\n",
       "        [-0.0063,  0.2665,  0.1769, -0.2042,  0.0453, -0.2571],\n",
       "        [-0.3118,  0.2224, -0.1354, -0.2542, -0.3551, -0.1368],\n",
       "        [ 0.3341,  0.3228,  0.3506,  0.1577, -0.1440, -0.1095],\n",
       "        [ 0.2347,  0.3186,  0.0292, -0.1495, -0.2789,  0.2274],\n",
       "        [-0.0188,  0.3715,  0.1009, -0.3488, -0.3148,  0.3386],\n",
       "        [ 0.1666,  0.3454,  0.3715, -0.0871,  0.3355, -0.0713]],\n",
       "       requires_grad=True)"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#embed vertices with a dimension of 6\n",
    "vert_em = nn.Embedding(g.number_of_nodes(),6) \n",
    "inputs = vert_em.weight                  \n",
    "nn.init.xavier_uniform_(inputs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "77f0ea2e",
   "metadata": {},
   "outputs": [],
   "source": [
    "#obtain labels and denote available labels for GNN learning (here: 1, 3, 5, 12, 15, 32)\n",
    "labels = g.ndata['label']\n",
    "labeled_nodes = [1, 3, 5, 12, 15, 32]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "351efc7e",
   "metadata": {},
   "outputs": [],
   "source": [
    "#build a three-layer GraphSAGE model\n",
    "class GraphSAGE(nn.Module):\n",
    "    def __init__(self, in_feats, h_feats1, h_feats2, num_classes):\n",
    "        super(GraphSAGE, self).__init__()\n",
    "        self.conv1 = SAGEConv(in_feats, h_feats1, 'mean')\n",
    "        self.conv2 = SAGEConv(h_feats1, h_feats2, 'mean')\n",
    "        self.conv3 = SAGEConv(h_feats2, num_classes, 'mean')\n",
    "    def forward(self, g, in_feat):\n",
    "        h = self.conv1(g, in_feat)\n",
    "        h = F.relu(h)\n",
    "        h = self.conv2(g, h)\n",
    "        h = F.relu(h)\n",
    "        h = self.conv3(g, h)\n",
    "        return h\n",
    "\n",
    "#6 embedding dimensions as input, a hidden layers of 8 and 6 nodes, and 2 classes to output\n",
    "net = GraphSAGE(6,8,6,2)\n",
    "\n",
    "#GNN training parameters\n",
    "optimizer=torch.optim.SGD(itertools.chain(net.parameters(), vert_em.parameters()),lr=0.01,\n",
    "                          momentum=0.8)\n",
    "all_logits = []\n",
    "\n",
    "#train GNN\n",
    "for e in range(990):\n",
    "    logits = net(g, inputs)\n",
    "    logp = F.log_softmax(logits, 1)\n",
    "    loss = F.nll_loss(logp[labeled_nodes], labels[labeled_nodes])\n",
    "    optimizer.zero_grad()\n",
    "    loss.backward()\n",
    "    optimizer.step()\n",
    "    all_logits.append(logits.detach())\n",
    "    if e % 90 == 0:\n",
    "        print('In epoch {}, loss: {}'.format(e, loss))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2e8aeaf6",
   "metadata": {},
   "outputs": [],
   "source": [
    "#obtain accuracy statistics\n",
    "pred = torch.argmax(logits, axis=1)\n",
    "print('Accuracy', (pred == labels).sum().item() / len(pred))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fd1297d5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
